import { Ellipsoid } from "../../../Source/QuarkGIS.js";
import { Globe } from "../../../Source/QuarkGIS.js";
import createScene from "../../createScene.js";
import { QuarkGISInspector } from "../../../Source/QuarkGIS.js";

describe(
  "Widgets/QuarkGISInspector/QuarkGISInspector",
  function () {
    var scene;
    beforeAll(function () {
      scene = createScene();
      var ellipsoid = Ellipsoid.UNIT_SPHERE;
      var globe = new Globe(ellipsoid);
      scene.globe = globe;
    });

    afterAll(function () {
      scene.destroyForSpecs();
    });

    it("can create and destroy", function () {
      var container = document.createElement("div");
      container.id = "testContainer";
      document.body.appendChild(container);

      var widget = new QuarkGISInspector("testContainer", scene);
      expect(widget.container).toBe(container);
      expect(widget.viewModel.scene).toBe(scene);
      expect(widget.isDestroyed()).toEqual(false);
      widget.destroy();
      expect(widget.isDestroyed()).toEqual(true);

      document.body.removeChild(container);
    });

    it("constructor throws with no element", function () {
      expect(function () {
        return new QuarkGISInspector();
      }).toThrowDeveloperError();
    });

    it("constructor throws with string element that does not exist", function () {
      expect(function () {
        return new QuarkGISInspector("does not exist", scene);
      }).toThrowDeveloperError();
    });

    it("constructor throws with no scene", function () {
      expect(function () {
        return new QuarkGISInspector(document.body);
      }).toThrowDeveloperError();
    });
  },
  "WebGL"
);
